/*
 * <p>Copyright® 2009-2022 东软 IT 实训中心版权所有。</p>
 */

package com.max.back.doctor.api;

import com.max.back.common.http.ResponseResult;
import com.max.back.doctor.form.PatientHistoryForm;
import com.max.back.doctor.form.groups.CreateAndGetExaminationId;
import com.max.back.doctor.service.CodeNameService;
import com.max.back.doctor.service.ExaminationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
* @description 
* 
* <p>
* <code>CheckApi</code>
*
* </p>
* @see 
* @author 辛凤文 forward.seen@foxmail.com
* @version 1.0 
* @time 2022/7/25 16:16 
*/

@CrossOrigin
@RestController
@RequestMapping("/doctor/check")
public class CheckApi {
    @Autowired
    private ExaminationService examinationService;

    @Autowired
    private CodeNameService codeNameService;

    @PostMapping("/createAndGetExaminationId")
    public ResponseResult<String> createAndGetExaminationId(
            @RequestBody
            @Validated(CreateAndGetExaminationId.class) PatientHistoryForm form){
        return  ResponseResult.getSuccessResult(
                examinationService.createAndGetExaminationId(form.getPatientHistoryId()));
    }

    @Deprecated
    @GetMapping("/createAndGetExaminationId2")
    public ResponseResult<String> createAndGetExaminationId2(String patientHistoryId){
        return  ResponseResult.getSuccessResult(
                examinationService.createAndGetExaminationId(patientHistoryId));
    }


    @GetMapping("/getChecksByType")
    public ResponseResult<Object> getChecksByType(String type){
        List<Map<String, Object>> mapsByType = codeNameService.getMapsByType(type);
        return ResponseResult.getSuccessResult(mapsByType);
    }

}